<template>
  <div class="app-container">
    <CommonTable ref="commonTable" :qo="qo" :baba="this" :need-load-dict-type="['system_faq_type']">
      <!-- 查询参数 -->
      <template slot="filterItems">
        <el-form-item label="关键字" prop="keyword">
          <el-input v-model.trim="qo.keyword" clearable />
        </el-form-item>
        <el-form-item label="类型" prop="type">
          <el-select v-model="qo.type" clearable>
            <el-option v-for="item in this.$store.getters.dictSelectData.system_faq_type" :key="item.value" :value="item.value" :label="item.label" />
          </el-select>
        </el-form-item>
      </template>
      <!-- 列表头 -->
      <template slot="column">
        <el-table-column label="问题" prop="question" />
        <el-table-column label="类型" prop="type">
          <template slot-scope="{row}">
            <el-tag type="success" effect="light">{{ 'system_faq_type'|transferDictValue(row.type) }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="序号" prop="seq" />
        <el-table-column label="创建时间" prop="dateCreated" />
        <el-table-column label="修改时间" prop="lastUpdated" />
      </template>
    </CommonTable>
  </div>
</template>
<script>
import { list, deleteFaq } from '@/api/system/faq'
import CommonTable from '@/components/CommonTable'
export default {
  name: 'Faq',
  components: { CommonTable },
  data() {
    return {
      qo: { keyword: '', type: '' }
    }
  },
  created() {
  },
  methods: {
    getData(qoPro) {
      return list(qoPro)
    },
    create() {
      this.$router.push({ path: '/system/faq/create' })
    },
    update(row) {
      this.$router.push({ path: '/system/faq/edit', query: { id: row.id }})
    },
    handleDelete(row) {
      this.$confirm('确认删除此问题', '提示', {
        type: 'warning'
      }).then(() => {
        const ld = this.$loading()
        setTimeout(() => {
          deleteFaq(row.id).then(res => {
            this.$notify.success('删除成功')
            ld.close()
            this.$refs.commonTable.refreshList()
          }).catch(() => { ld.close() })
        }, 400)
      }).catch(() => {})
    }
  }
}
</script>
